<template>
  <div class="input_text_block " @click="CallBack()">
    <div role="button" tabindex="0" class="input_text van-cell">
      <div class="van-cell__title van-field__label" style="width: 100px;margin: auto 10;">
        {{ label }}
      </div>
      <vue-datepicker-local
        v-model="timeName"
        :format="formats"
      ></vue-datepicker-local>
    </div>
  </div>
</template>

<script>
// 文件描述：   日期格式控件
//创建人：高先生 https://weifeiyue.github.io/vue-datepicker-local/
import VueDatepickerLocal from "vue-datepicker-local";
export default {
  props: {
    // timeName: {
    //   type: String,
    //   required: new Date(),
    // },
    labelName: {
      type: String,
      required: false,
    },
    formatName: {
      type: String,
      required: false,
    },
  },
  components: {
    VueDatepickerLocal,
  },
  data() {
    return {
      label: "日历",
      formats: "YYYY-MM-DD",
      timeName:new Date(),
    };
  },
  created() {
    if (this.labelName) {
      this.label = this.labelName;
    }
    if (this.formatName) {
      this.formats = this.formatName;
    }
    if (this.timeName) {
      this.timeName = new Date(this.timeName);
    }
  },
  methods: {
    CallBack() {
      //忘记怎么取值了就看看这个打印例子
      //               var d = new Date('Thu May 12 2016 08:00:00 GMT+0800 (中国标准时间)');
      // var  youWant=d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
      //        console.log("https======time=>", youWant);

      this.$emit("CallBack", this.timeName.getFullYear().toString());
    },
  },
};
</script>

<style lang="less" scoped>
.van-cell {
  overflow: inherit;
}
</style>
